<?php
/** 
 * $Source: /cvsroot/pn-commerce/pn-commerce/pntemplates/plugins/function.pncColumnSort.php,v $
 * $Author: landseer $
 * $Revision: 1.4 $
 * $Date: 2004/04/28 12:43:23 $
 *
 * Type: Function
 *
 * creates a complete arrow up/arrow field where the user can select the sorting of the item list 
 *@param params['SortBy'] string name of the field in the database to sort 
 *@param params['Up'] (optional) image to show as "arrow up"
 *@param params['Down'] (optional) image to show as "arrow down"
 *@return string complete <select></select statement with all options
 */
function smarty_function_pncColumnSort($params, &$smarty)
{
    extract($params);

    if( !$SortBy )
    {
        $smarty->trigger_error( "pncColumnSort: missing parameter SortBy" );
        return false;
    }
    if( !$Up )
    {
        $Up = "modules/pncommerce/pnimages/up.gif";
    }
    if( !$Down )
    {
        $Down = "modules/pncommerce/pnimages/dn.gif";
    }
    
    if( pnModAPILoad('pncommerce','user') )
    {
        $upurl = pnModAPIFunc( 'pncommerce',  'user', 'pncModURL',
                                array( 'Module' => 'pncommerce',
                                       'Section' => 'user',
                                       'Function' => 'categoryview',
                                       'Args' => array( 'sortby' => $SortBy,
                                                     'sortorder' => 'asc' ) ) );
        $dnurl = pnModAPIFunc( 'pncommerce',  'user', 'pncModURL',
                                array( 'Module' => 'pncommerce',
                                       'Section' => 'user',
                                       'Function' => 'categoryview',
                                       'Args' => array( 'sortby' => $SortBy,
                                                     'sortorder' => 'desc' ) ) );
        
        $temp  = "<a href=\"$upurl\"><img src='$Up' border='0' alt='up'></a>";
        $temp .= "<a href=\"$dnurl\"><img src='$Down' border='0' alt='down'></a>";
        return $temp;
    }
    else
    {
        $smarty->trigger_error( "pncColumnSort: cannot load pnuserapi", E_USER_ERROR );
        return false;
    }
}
?>
